#include "./c_tool.h"

int * ToolSwap(int array[], int x, int y) {
  int temp = array[x];
  array[x] = array[y];
  array[y] = temp;
  return array;
}

void ToolPrintRunTime(clock_t start, clock_t end) {
  double cost_time = (double)(end - start) / CLOCKS_PER_SEC;
  printf("\n代码的执行时间为%f毫秒\n", cost_time);
}

void ToolPrintArray(int array[], int length) {
  printf("\n");
  int lastIndex = length - 1;
  for (int i = 0; i < length; i++) {
    printf("%d", array[i]);
    if (i < lastIndex) {
      printf(", ");
    }
  }
  printf("\n");
}